home *** CD-ROM | disk | FTP | other *** search
/ Carousel / CAROUSEL.cdr / mactosh / util / simulare.sit / Simula 4.07 Reference / card_33570.txt < prev    next >
Text File  |  1989-05-02  |  2KB  |  81 lines

  1. -- card: 33570 from stack: in.07 Reference
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 13647
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (field)
  9. -- low flags: 00
  10. -- high flags: 0002
  11. -- rect: left=309 top=67 right=292 bottom=463
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 0
  15. -- font id: 3
  16. -- text size: 9
  17. -- style flags: 8192
  18. -- line height: 12
  19. -- part name: 
  20.  
  21.  
  22. -- part 2 (button)
  23. -- low flags: 00
  24. -- high flags: A004
  25. -- rect: left=81 top=245 right=267 bottom=165
  26. -- title width / last selected line: 0
  27. -- icon id / first selected line: 0 / 0
  28. -- text alignment: 1
  29. -- font id: 0
  30. -- text size: 12
  31. -- style flags: 0
  32. -- line height: 16
  33. -- part name: Parameters
  34. ----- HyperTalk script -----
  35. on mouseUp
  36.   go to card id 40406
  37. end mouseUp
  38.  
  39.  
  40.  
  41.  
  42. -- part contents for background part 1
  43. ----- text -----
  44.  
  45. The user can define his own types with the 
  46. Class mechanism. Class abstractions contain 
  47. both data and operations. These are all called 
  48. attributes of the class. 
  49.  
  50. Each instance of a class (an object) has its own 
  51. copy of the attributes. When an object is created  
  52. the parameters must be supplied and its body is 
  53. executed.
  54.  
  55.  
  56.  
  57.  
  58.  
  59. -- part contents for background part 2
  60. ----- text -----
  61. Class definition
  62.  
  63. -- part contents for card part 1
  64. ----- text -----
  65. class Stack(size); integer size;
  66. begin   integer Top;
  67.      integer array Storage(1:size);
  68.      procedure Push(v); integer v;
  69.      begin 
  70.           if Top>Size then Error("Overflow");
  71.           Top:=Top+1; Storage(Top):=v;
  72.      end --- Push --- ;
  73.      integer procedure Pop;
  74.      begin
  75.         if Top=0 then Error("Underflow");
  76.         Pop:=Storage(Top); Top:=Top-1;
  77.      end -- Pop --- ;
  78.  
  79.     !  ---- class body ---- ;
  80.    Top:=0;
  81. end --- Stack ---;